import { createRouter, createWebHistory } from "vue-router";
import Home from "../components/Home.vue";

const router = createRouter({
  history: createWebHistory(), //路由器的开发模式
  routes: [
    {
      name: "shouye",
      path: "/home",
      component: Home,
    },
    {
      name: "xinwen",
      path: "/news",
      component: () => import("../components/News.vue"), //路由懒加载
      children: [
        {
          name: "xijie",
          path: "detail/:id/:title/:content",
          component: () => import("../components/Detail.vue"), //路由懒加载
          props: true,
        },
      ],
    },
    {
      name: "guanyu",
      path: "/about",
      component: () => import("../components/About.vue"), //路由懒加载
    },
    {
      name: "login",
      path: "/login",
      component: () => import("../views/Login.vue"), //路由懒加载
    },
    {
      name: "fuzujian",
      path: "/start",
      component: () => import("../components/start.vue"), //路由懒加载
    },
    {
      name: "slotpage",
      path: "/slotpage",
      component: () => import("../components/slotpage.vue"), //路由懒加载
    },
    {
      path: "/",
      redirect: "./home", //重定向
    },
  ],
});
export default router;
